*REPLICATION CODE for Nanes, Ravanilla, and Haim, "Fire Alarms for Police Patrols: Experimental Evidence on Co-Production of Public Safety"
*Journal of Politics
*Code - Matthew Nanes 12/19/2019

cd "~/Dropbox\DHN Philippine Police\3. EGAP (POP - One Sorsogon Reloaded)\3.12 - Articles and Chapters\3.12.2 Fire Alarms for Police Patrols\JOP\5. Replication Files"


****Open the citizen survey data****
use "Nanes et al JOP Fire Alarms survey data.dta", clear 


*Summary stats on crime victimization (mentioned in text)
tab crime_num
tab ccrime_num

******************************************************
****TABLE 1: Effects of Hotline on Crime Reporting****
******************************************************

eststo clear
eststo: reg crime_reporting_idx_a_ln Z_tipline Z_common if ccrime_num!=0, cl(psgc)
eststo: reg crime_reporting_idx_a_ln Z_tipline Z_common age education income8 reside_decade crowd distance if ccrime_num!=0, cl(psgc)
eststo: reg crime_report_num Z_tipline Z_common age education income8 reside_decade crowd distance if crime_num!=0, cl(psgc)
eststo: reg ccrime_report_num Z_tipline Z_common age education income8 reside_decade crowd distance if ccrime_num!=0, cl(psgc)
esttab using "sms_reportcrime.tex", se star(* .10 ** .05 *** .01) r2 nodep mtitle("Index" "Index" "Personal" "Community") label title(Effects of Hotline on Crime Reporting \label{tab:reporting}) note(OLS with barangay-clustered SE in parentheses.) replace

reg crime_reporting_idx_a_ln Z_tipline Z_common age education income8 reside_decade crowd distance if ccrime_num!=0, cl(psgc)
predict crimerep_val, xb
predict crimerep_se, stdp

******************************************************
**TABLE 2: Effects of Hotline on Crime Victimization**
******************************************************

eststo clear
eststo: reg vic_robbery Z_tipline Z_common age education income8 reside_decade crowd distance, cl(psgc)
eststo: reg vic_theft Z_tipline Z_common age education income8 reside_decade crowd distance, cl(psgc)
eststo: reg vic_assault Z_tipline Z_common age education income8 reside_decade crowd distance, cl(psgc)
eststo: reg issues_victim_drugs Z_tipline Z_common age education income8 reside_decade crowd distance, cl(psgc)
eststo: reg issues_victim_npa Z_tipline Z_common age education income8 reside_decade crowd distance, cl(psgc)
esttab using "othercrimes.tex", se star(* .10 ** .05 *** .01) r2 nodep mtitle ("Armed Robbery" "Burglary" "Assault" "Drugs" "Insurgents") label title(Effects of Hotline on Crime Victimization \label{tab:crime}) note(OLS with barangay-clustered SE in parentheses.) replace

*****************************************************************
***TABLE 3: Effects of Hotline on Attitudes Towards the Police***
*****************************************************************

eststo clear
eststo: reg satis_change Z_tipline Z_common age education income8 reside_decade crowd distance, cl(psgc)
eststo: reg obeynorm1 Z_tipline Z_common age education income8 reside_decade crowd distance, cl(psgc)
eststo: reg responsive_act Z_tipline Z_common age education income8 reside_decade crowd distance, cl(psgc)
eststo: reg satis_trust Z_tipline Z_common age education income8 reside_decade crowd distance, cl(psgc)
eststo: reg issues_satis_npa Z_tipline Z_common age education income8 reside_decade crowd distance, cl(psgc)
esttab using "attitudes.tex", se star(* .10 ** .05 *** .01) r2 nodep mtitle ("Satisfaction)" "Legitimacy" "Responsiveness" "Trust" "Satisfaction (NPA)") label title(Effects of Hotline on Attitudes Towards Police \label{tab:attitudes}) note(OLS with barangay-clustered SE in parentheses.) replace

********************************************************
***SI TABLE 2: Balance on 2010 Census Characteristics***
********************************************************

gen tip_group=0 if Z_common==0
replace tip_group=1 if Z_common==1
replace tip_group=2 if Z_tipline==1
label define tipgroup 0 "Control" 1 "CEP" 2 "Tipline"
label values tip_group tipgroup
label variable CEP "Community Pol."
label variable tipline "Hotline"

eststo clear
foreach var in c10_population c10_male c10_hhsize c10_ofw c10_education c10_age18_39 c10_catholic {
	eststo: reg `var' tipline CEP, cl(psgc)
	}
esttab using "balance_c10_tipline.tex", se star(* .10 ** .05 *** .01) r2 nodep mtitle ("Population" "Male" "HH Size" "OFWs" "Education" "Age 18-39" "Catholic") label title(Balance on 2010 Census Characteristics \label{tab:c10balance}) note(OLS with barangay-clustered SE in parentheses.) replace

************************
***SI TABLE 3: Uptake***
************************

eststo clear
eststo: reg sms_claimed Z_tipline age education income8 reside_decade crowd distance, cl(psgc)
eststo: reg sms_saved Z_tipline age education income8 reside_decade crowd distance, cl(psgc)
eststo: reg phone_saved Z_tipline age education income8 reside_decade crowd distance, cl(psgc)
esttab using "uptake.tex", se star(* .10 ** .05 *** .01) r2 nodep mtitle ("Hotline Claimed" "Hotline Saved" "Any Numb Saved") label title(Uptake \label{tab:uptake}) note(OLS with barangay-clustered SE in parentheses.) replace

***************************************************************************************
***SI TABLE 4: Balance on Pre-Treatment Observables Among Victims of Crime (Hotline)***
***************************************************************************************

ttest male if ccrime_num!=0, by(Z_tipline)
ttest age if ccrime_num!=0, by(Z_tipline)
ttest education if ccrime_num!=0, by(Z_tipline)
ttest income if ccrime_num!=0, by(Z_tipline)
ttest reside_decade if ccrime_num!=0, by(Z_tipline)
ttest distance if ccrime_num!=0, by(Z_tipline)

*****************************************************************************************************
***SI TABLE 5: Balance on Pre-Treatment Observables Among Victims of Crime (Alternative Treatment)***
*****************************************************************************************************

ttest male if ccrime_num!=0, by(Z_common)
ttest age if ccrime_num!=0, by(Z_common)
ttest education if ccrime_num!=0, by(Z_common)
ttest income if ccrime_num!=0, by(Z_common)
ttest reside_decade if ccrime_num!=0, by(Z_common)
ttest distance if ccrime_num!=0, by(Z_common)

******************************************************************************
***SI TABLE 6: Effects of Hotline on Crime Reporting, Unconditioned Results***
******************************************************************************

*gen ccrime_any (a)
gen ccrime_any=ccrime_num
replace ccrime_any=1 if ccrime_num>0
replace ccrime_any=. if ccrime_num==.
label variable ccrime_any "Crime (comm.)"

*gen ccrime_vicrep (b)
gen ccrime_vicrep=ccrime_any
replace ccrime_vicrep=0 if ccrime_report_num==0
replace ccrime_vicrep=. if ccrime_num==.
replace ccrime_vicrep=. if ccrime_report_num==.
label variable ccrime_vicrep "Crime (comm.) reported"

*gen ccrime_vicunrep (c)
gen ccrime_vicunrep=ccrime_any
replace ccrime_vicunrep=0 if ccrime_report_num>0 & ccrime_any>0
replace ccrime_vicunrep=. if ccrime_num==.
replace ccrime_vicunrep=. if ccrime_report_num==.
label variable ccrime_vicunrep "Crime (comm.) Unreported"

*regressions
eststo clear
eststo: reg crime_reporting_idx_a_ln Z_tipline Z_common age education income8 reside_decade crowd distance, cl(psgc)
eststo: reg ccrime_any Z_tipline Z_common age education income8 reside_decade crowd distance, cl(psgc)
eststo: reg ccrime_vicrep Z_tipline Z_common age education income8 reside_decade crowd distance, cl(psgc)
eststo: reg ccrime_vicunrep Z_tipline Z_common age education income8 reside_decade crowd distance, cl(psgc)
esttab using "sms_reportcrime_alt.tex", se star(* .10 ** .05 *** .01) r2 nodep mtitle("Index" "Experienced Crime" "Reported Crime" "Unreported Crime") label title(Effects of Hotline on Crime Reporting, Unconditioned Results \label{tab:reportingAlt}) note(OLS with barangay-clustered SE in parentheses.) replace

****************************************************************************************
***SI TABLE 7: Most important public safety issues according to officers and citizens***
****************************************************************************************

*Center column (civilians)
foreach issue in intox theft gambling polabuse sexharass robbery carnap vehicle firearms domabuse murder drugs rape {
	tab top3_`issue'
	}

*Left column (police officers)
****Open the police officer survey data****
use "Nanes et al JOP Fire Alarms police survey.dta", clear

foreach issue in intox theft gambling polabuse sexharass robbery carnap vehicle firearms domabuse murder drugs rape {
	tab top3_pnp_`issue'
	}

*Additional officer attitudes mentioned in text
sum trust_info
sum empathy_report
sum info_important	
sum npa_sympathy

*********************************************************************
***SI TABLE 8: Heterogeneous Effects of Hotline on Crime Reporting***
*********************************************************************

****Re-open the citizen survey data****
use "Nanes et al JOP Fire Alarms survey data.dta", clear 

eststo clear
eststo: reg crime_reporting_idx_a_ln Z_tipline Z_common age Z_tipline#c.age education Z_tipline#c.education income8 Z_tipline#c.income8 reside_decade Z_tipline#c.reside_decade crowd Z_tipline#crowd distance Z_tipline#c.distance if ccrime_num!=0, cl(psgc)
eststo: reg crime_report_num Z_tipline Z_common age Z_tipline#c.age education Z_tipline#c.education income8 Z_tipline#c.income8 reside_decade Z_tipline#c.reside_decade crowd Z_tipline#crowd distance Z_tipline#c.distance if ccrime_num!=0, cl(psgc)
eststo: reg ccrime_report_num Z_tipline Z_common age Z_tipline#c.age education Z_tipline#c.education income8 Z_tipline#c.income8 reside_decade Z_tipline#c.reside_decade crowd Z_tipline#crowd distance Z_tipline#c.distance if ccrime_num!=0, cl(psgc)
esttab using "sms_reportcrime_interact.tex", se star(* .10 ** .05 *** .01) r2 nodep mtitle("Index" "Personal" "Community") label title(Heterogeneous Effects of SMS Tipline on Crime Reporting \label{tab:reporting_het}) note(OLS with barangay-clustered SE in parentheses.) replace

**************************************************
***SI TABLE 9: Effects of SI on Clearance Rates***
**************************************************

****Open the adminstrative incident-level data****
use "Nanes et al JOP Fire Alarms admin data.dta", clear

label variable Z_common "Community Pol."
encode mun, gen(mun2)
eststo clear
xtset mun2
eststo: logit outcome_resolved Z_tipline Z_common if midline==1, cl(psgc)
eststo: xtlogit outcome_resolved Z_tipline Z_common if midline==1, vce(cluster mun2)
xtset psgc
eststo: xtlogit outcome_resolved Z_tipline Z_common if midline==1, vce(cluster psgc)
esttab using "sms_resolved.tex", se star(* .10 ** .05 *** .01) nodep mtitle("" "" "") label title(Effects of Hotline on Clearance Rates \label{tab:clearance}) note(Logistic regression.) replace

**Statistics from administrative data mentioned in-text
*How is each type of crime reported to the police?
foreach crime in aarmedrob aburglary aaggassault asexual amurder anpa {
	tab reportmethod if `crime'==1
	}

*Analysis by reporting method / crime type / treatment condition / time
gen rep_hotline = rep_phone + rep_sms
gen rep_nothotline = rep_inperson + rep_polops + rep_surrender

foreach crime in aarmedrob aburglary aaggassault asexual amurder anpa aother {
	gen rep_hotline_`crime' = 0
	replace rep_hotline_`crime' = 1 if rep_hotline==1 & `crime'==1
	gen rep_nh_`crime' = 0
	replace rep_nh_`crime' = 1 if rep_nothotline==1 & `crime'==1
	}
	
replace baseline=0 if baseline==.
replace midline=0 if midline==.
replace endline=0 if endline==.
gen period=0
replace period=1 if baseline==1
replace period=2 if midline==1
replace period=3 if endline==1

collapse (sum) rep_hotline_aarmedrob rep_hotline_aburglary rep_hotline_aaggassault rep_hotline_asexual rep_hotline_amurder rep_hotline_anpa rep_hotline_aother rep_nh_aarmedrob rep_nh_aburglary rep_nh_aaggassault rep_nh_asexual rep_nh_amurder rep_nh_anpa rep_nh_aother, by(period Z_tipline)
drop if Z_tipline==.

gen rep_hot_aarmedrob_p = rep_hotline_aarmedrob / (rep_hotline_aarmedrob + rep_nh_aarmedrob)
gen rep_hot_aburglary_p = rep_hotline_aburglary / (rep_hotline_aburglary + rep_nh_aburglary)
gen rep_hot_aaggassault_p = rep_hotline_aaggassault / (rep_hotline_aaggassault + rep_nh_aaggassault)
gen rep_hot_asexual_p = rep_hotline_asexual / (rep_hotline_asexual + rep_nh_asexual)
gen rep_hot_amurder_p = rep_hotline_amurder / (rep_hotline_amurder + rep_nh_amurder)
gen rep_hot_anpa_p = rep_hotline_anpa / (rep_hotline_anpa + rep_nh_anpa)
gen rep_hot_aother_p = rep_hotline_aother / (rep_hotline_aother + rep_nh_aother)

label variable rep_hot_aarmedrob_p "Armed Robbery"
label variable rep_hot_aburglary_p "Burglary"
label variable rep_hot_aaggassault_p "Aggravated Assault"
label variable rep_hot_asexual_p "Sexual Assault"
label variable rep_hot_amurder_p "Murder"
label variable rep_hot_anpa_p "Insurgents"
label variable rep_hot_aother_p "Other"

label define Period 1 "Pre" 2 "Post"
label values period Period

label define Treatment 0 "Control" 1 "Treatment"
label values Z_tipline Treatment
label variable Z_tipline "Hotline"

************************************************
***SI Figure 1: Reporting Methods by Crime Type**
************************************************

graph bar (asis) rep_hot_aarmedrob_p  rep_hot_aother_p rep_hot_anpa_p rep_hot_amurder_p rep_hot_asexual_p rep_hot_aaggassault_p rep_hot_aburglary_p if period==1 | period==2, ytitle(Percentage) by(, title(Percentage of Crimes Reported via Phone or SMS)) scheme(s1color) by(Z_tipline period)

**************************************************
***TABLE 10: Effects of Hotline on NPA Activity***
**************************************************

****Re-open the citizen survey data****
use "Nanes et al JOP Fire Alarms survey data.dta", clear 

eststo clear
eststo: reg issues_problem_npa Z_tipline Z_common age education income8 reside_decade crowd distance, cl(psgc)
eststo: reg issues_satis_npa Z_tipline Z_common age education income8 reside_decade crowd distance, cl(psgc)
esttab using "npaissues.tex", se star(* .10 ** .05 *** .01) r2 nodep mtitle ("Problem" "Satisfaction") label order(Z_tipline Z_common) title(Effects of Hotline on Insurgent Activity \label{tab:npa}) note(OLS with barangay-clustered SE in parentheses.) replace

**************************************************
***TABLE 11: Could you please tell me how well you think the police are doing at dealing with these types of crime within the last 6 months? Armed Rebel Group
**************************************************

eststo clear
eststo: reg issues_satis_npa issues_problem_npa, cl(psgc)
eststo: reg issues_satis_npa issues_problem_npa age education income8 reside_decade crowd distance, cl(psgc)
eststo: reg issues_satis_npa issues_victim_npa, cl(psgc)
eststo: reg issues_satis_npa issues_victim_npa age education income8 reside_decade crowd distance, cl(psgc)
esttab using "npa_satisfaction.tex", se star(* .10 ** .05 *** .01) r2 nodep mtitle ("" "" "" "") label title(Could you please tell me how well you think the police are doing at dealing with these types of crime within the last 6 months? Armed Rebel Group \label{tab:satisnpa}) note(Responses range from -2 (least satisfied) to 2 (most satisfied). OLS with barangay-clustered SE in parentheses.) replace

**************************************************************
***TABLE 12: Effects of Hotline-Adjacent on Crime Reporting***
**************************************************************

*Merge in data on neighbors' treatment status
merge m:1 psgc using "Nanes et al JOP Fire Alarms treated neighbors.dta"

*Variables "nbr_z_[treatment]" denote whether at least one neighboring barangay received the treatment
drop if _merge==1
drop _merge

label variable nbr_z_common "Comm. Pol. Adjacent"
label variable nbr_z_tipline "Hotline Adjacent"

eststo clear
eststo: reg crime_reporting_idx_a_ln Z_tipline Z_common nbr_z_tipline nbr_z_common if ccrime_num!=0, cl(psgc)
eststo: reg crime_reporting_idx_a_ln Z_tipline Z_common nbr_z_tipline nbr_z_common age education income8 reside_decade crowd distance if ccrime_num!=0, cl(psgc)
eststo: reg crime_report_num Z_tipline Z_common nbr_z_tipline nbr_z_common age education income8 reside_decade crowd distance if crime_num!=0, cl(psgc)
eststo: reg ccrime_report_num Z_tipline Z_common nbr_z_tipline nbr_z_common age education income8 reside_decade crowd distance if ccrime_num!=0, cl(psgc)
esttab using "sms_reportcrime_nbr.tex", se star(* .10 ** .05 *** .01) r2 nodep mtitle("Index" "Index" "Personal" "Community") label title(Effects of Hotline-Adjacent on Crime Reporting \label{tab:reportingnbr}) note(OLS with barangay-clustered SE in parentheses.) replace

******************************************************************
***TABLE 13: Effects of Hotline-Adjacent on Crime Victimization***
******************************************************************

eststo clear
eststo: reg vic_robbery Z_tipline Z_common nbr_z_tipline nbr_z_common age education income8 reside_decade crowd distance, cl(psgc)
eststo: reg vic_theft Z_tipline Z_common nbr_z_tipline nbr_z_common age education income8 reside_decade crowd distance, cl(psgc)
eststo: reg vic_assault Z_tipline Z_common nbr_z_tipline nbr_z_common age education income8 reside_decade crowd distance, cl(psgc)
eststo: reg issues_victim_drugs Z_tipline Z_common nbr_z_tipline nbr_z_common age education income8 reside_decade crowd distance, cl(psgc)
eststo: reg issues_victim_npa Z_tipline Z_common nbr_z_tipline nbr_z_common age education income8 reside_decade crowd distance, cl(psgc)
esttab using "othercrimes_nbr.tex", se star(* .10 ** .05 *** .01) r2 nodep mtitle ("Armed Robbery" "Burglary" "Assault" "Drugs" "Insurgents") label title(Effects of Hotline-Adjacent on Crime Victimization \label{tab:crimenbr}) note(OLS with barangay-clustered SE in parentheses.) replace

*********************************************************************	
***TABLE 14: Effects of Hotline on Crime Reporting (Second Survey)***
*********************************************************************

use "Nanes et al JOP Fire Alarms second survey.dta", clear

eststo clear
eststo: reg crime_reporting_idx_a_ln Z_tipline if ccrime_num!=0, cl(psgc)
eststo: reg crime_reporting_idx_a_ln Z_tipline age education income8 reside_decade crowd distance if ccrime_num!=0 & Z_common==1, cl(psgc)
eststo: reg crime_report_num Z_tipline age education income8 reside_decade crowd distance if crime_num!=0, cl(psgc)
eststo: reg ccrime_report_num Z_tipline age education income8 reside_decade crowd distance if ccrime_num!=0, cl(psgc)
esttab using "sms_reportcrime_end.tex", se star(* .10 ** .05 *** .01) r2 nodep mtitle("Index" "Index" "Personal" "Community") label title(Effects of Hotline on Crime Reporting (Second Survey) \label{tab:reportingend}) note(OLS with barangay-clustered SE in parentheses.) replace

*************************************************************************
***TABLE 15: Effects of Hotline on Crime Victimization (Second Survey)***
*************************************************************************

eststo clear
eststo: reg vic_robbery Z_tipline age education income8 reside_decade crowd distance, cl(psgc)
eststo: reg vic_theft Z_tipline age education income8 reside_decade crowd distance, cl(psgc)
eststo: reg vic_assault Z_tipline age education income8 reside_decade crowd distance, cl(psgc)
eststo: reg issues_victim_drugs Z_tipline age education income8 reside_decade crowd distance, cl(psgc)
eststo: reg issues_victim_npa Z_tipline age education income8 reside_decade crowd distance, cl(psgc)
esttab using "othercrimes_end.tex", se star(* .10 ** .05 *** .01) r2 nodep mtitle ("Armed Robbery" "Burglary" "Assault" "Drugs" "Insurgents") label title(Effects of Hotline on Crime Victimization (Second Survey) \label{tab:crimeend}) note(OLS with barangay-clustered SE in parentheses.) replace

******************************************************************************
***TABLE 16: Effects of Hotline on Attitudes Towards Police (Second Survey)***
******************************************************************************

eststo clear
eststo: reg satis_change Z_tipline age education income8 reside_decade crowd distance, cl(psgc)
eststo: reg obeynorm1 Z_tipline age education income8 reside_decade crowd distance, cl(psgc)
eststo: reg responsive_act Z_tipline age education income8 reside_decade crowd distance, cl(psgc)
eststo: reg satis_trust Z_tipline age education income8 reside_decade crowd distance, cl(psgc)
esttab using "attitudes_end.tex", se star(* .10 ** .05 *** .01) r2 nodep mtitle ("Satisfaction (change)" "Legitimacy" "Responsiveness" "Trust") label title(Effects of Hotline on Attitudes Towards Police (Second Survey) \label{tab:attitudesend}) note(OLS with barangay-clustered SE in parentheses.) replace


